package org.stvd.repository.quartz.impl;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.stvd.core.dto.QueryResult;
import org.stvd.entities.quartz.QuartzJob;
import org.stvd.repository.base.impl.BaseDaoImpl;
import org.stvd.repository.quartz.QuartzJobDao;

/**
 * @title QuartzJobDaoImpl
 * @description 定时任务数据层接口实现
 * @auther houzx
 * @date 2022年03月10日
 */
@Repository("QuartzJobDao")
public class QuartzJobDaoImpl extends BaseDaoImpl<QuartzJob> implements QuartzJobDao {

    @Override
    public QueryResult<QuartzJob> queryQuartzJobResult(int start, int limit, QuartzJob quartzJob) {
        String hql = "FROM QuartzJob WHERE jobName LIKE ?0 AND (status = ?1 OR '' = ?1) ORDER BY orderNo DESC";
        return getQueryResultByHQL(start, limit, hql, "%"+quartzJob.getJobName()+"%", quartzJob.getStatus());
    }

    @Override
    public List<QuartzJob> listEnabledQuartzJob() {
        return findByHQL("FROM QuartzJob WHERE status = 'NORMAL' ORDER BY orderNo DESC");
    }
}
